home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / basic / PureBasic.lha / PureBasic_Demo / PureBasic / Examples / FullVersion_Sources / Commodity1.pb < prev    next >
Encoding:
Text File  |  2000-03-19  |  3.5 KB  |  123 lines

  1.  
  2. ; *************************************
  3. ;
  4. ; Commodity example file for Pure Basic
  5. ;
  6. ; © 1999 - Fantaisie Software -
  7. ;
  8. ; *************************************
  9.  
  10.  
  11. ; This example show the basic idea of how
  12. ; a Commodity should be built, with the
  13. ; eventloop and how to react on commands
  14. ; from Commodities Exchange.
  15.  
  16.  
  17.  
  18.   name$="Pure Basic Commodity" ; this text is what..
  19.   title$="Commodity V1.00"     ; Commodities Exchange..
  20.   disc$="Testing"              ; show in it's window
  21.  
  22.  
  23.   PrintN("")
  24.   PrintN("/////////////////////////////////////////////")
  25.   PrintN("Press F1, F2 or open Commodities Exchange and")
  26.   PrintN("see what could be done on a Commodity there.")
  27.   PrintN("Press Ctrl C or start the Commodity a second")
  28.   PrintN("time to quit.")
  29.   PrintN("/////////////////////////////////////////////")
  30.   PrintN("")
  31.  
  32.  
  33.   If InitCommodity(1,name$,title$,disc$,4,0)   ;* this call is really a must
  34.  
  35.     txt$="f1"
  36.     err.b=CreateCommodityObject(0,txt$,0)      ;* Object 0 is tied to f1 key
  37.  
  38.     err=CreateCommodityObject(1,"f9",0) | err  ;* Object 1 is tied to f9 key
  39.  
  40.     err=ChangeCommodityFilter(1,"f2") | err    ;* change Object 1 to f2 key
  41.  
  42.  
  43.     If err = 0             ;* if there is no error on the filters..
  44.  
  45.       ActivateCommodity(1) ;* then it's time to activate the Commodity
  46.   
  47.  
  48.       Repeat                       ;* here starts the eventloop
  49.  
  50.       WaitCommodityEvent()         ;* wait until some event occur
  51.  
  52.  
  53.       If CommoditySignal()         ;* is the event a Commodity signal..
  54.  
  55.         msgtype.w=CommodityType()  ;* then get the Message Type..
  56.         msgid.w=CommodityID()      ;* and the Message ID
  57.  
  58.         Select msgtype
  59.  
  60.          Case #CXM_IEVENT                  ;* is Message of event Type
  61.  
  62.            Print("IEvent: ID=") : PrintNumber(msgid)
  63.  
  64.            Select msgid                    ;* the event was caused..
  65.  
  66.             Case 0                         ;* by Object 0
  67.               PrintN("  F1 was pressed..")
  68.  
  69.             Case 1                         ;* by Object 1
  70.               PrintN("  F2 was pressed..")
  71.  
  72.            EndSelect
  73.   
  74.  
  75.          Case #CXM_COMMAND                 ;* is Message of command Type
  76.            Print("Command: ")
  77.  
  78.            Select msgid                    ;* the command is a..
  79.  
  80.             Case #CXCMD_ENABLE             ;* Enable command
  81.               PrintN("Enable")
  82.               ActivateCommodity(1)         ;* then enable the Commodity
  83.  
  84.             Case #CXCMD_DISABLE            ;* Disable command
  85.               PrintN("Disable")
  86.               ActivateCommodity(0)         ;* then disable the Commodity
  87.  
  88.             Case #CXCMD_APPEAR             ;* Appear command
  89.               PrintN("Appear")             ;* then let the GUI appear
  90.  
  91.             Case #CXCMD_DISAPPEAR          ;* Disappear command
  92.               PrintN("DisAppear")          ;* then let the GUI disappear
  93.  
  94.             Case #CXCMD_KILL               ;* Kill command
  95.               PrintN("Kill")
  96.               quit=1                       ;* kill the Commodity
  97.  
  98.             Case #CXCMD_UNIQUE             ;* Unique command
  99.               PrintN("Unique")             ;* time for Commodity to quit if
  100.               quit=1                       ;* it has no GUI else show the GUI
  101.  
  102.            EndSelect
  103.  
  104.         EndSelect
  105.   
  106.       EndIf
  107.   
  108.  
  109.       If CommodityCtrlCSignal()  ;* is the event a Ctrl C break signal
  110.         quit=1                   ;* time for commodity to quit
  111.       EndIf
  112.   
  113.  
  114.       Until quit = 1             ;* here ends the eventloop
  115.  
  116.     EndIf
  117.  
  118.   EndIf
  119.   PrintN("End of Program.")
  120.  
  121.   End
  122.  
  123.